{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        
        <form action="{:request()->url()}" class="layui-form" method="post" enctype="multipart/form-data" onsubmit="return false;">
        
         <div class="layui-form-item">
                <label class="layui-form-label">轮播图片</label>
                <div class="layui-input-inline">
                    <div class="layui-avatar-img" id="ajax-admin-avatar" style="line-height:60px;border-radius: 4px;border: none;">
                        <input type="hidden" name="image" value="" autocomplete="off" placeholder="" class="layui-input">
                        <input type="hidden" name="filesize" id="filesize" value="">
                        <input type="hidden" name="mine" id="mine" value="">
                        <img id="image" src="{$model.url|default=seo('image')}" height="60" width="180">
                    </div>
                </div>
            </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('describe')}</label>
            <div class="layui-input-block">
                <input type="text" name="desc" id="desc" style="width: 80%" value="{$data.desc|default=''}" lay-verify="required"
                       placeholder="{:__('describe')}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Jump link')}</label>
            <div class="layui-input-block">
                <input type="text" name="url" id="url" style="width: 80%" value="{$data.url|default=''}"
                       placeholder="{:__('Jump link')}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('sort')}</label>
            <div class="layui-input-block">
                <input type="text" name="weigh" id="weigh" style="width: 80%" value="{$data.weigh|default=''}" placeholder="{:__('Please input sort')}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('state')}</label>
            <div class="layui-input-block" style="width:80px;">
                <select class="layui-input" name="status" id="status" lay-verify="required" lay-search="">
                    <option value="1" {if isset($data.status) and $data.status == '1'}Selected{/if}>正常</option>
                    <option value="0" {if isset($data.status) and $data.status == '0'}Selected{/if}>禁用</option> 
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" lay-filter="save" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger close">关闭</button>
            </div>
        </div>
    </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
layui.use(function () {
            // Tab的切换功能，切换事件监听等，需要依赖element模块
            var $ = layui.jquery, table = layui.table, element = layui.element;

            var upload = layui.upload;
             var form = layui.form;
             var $ = layui.jquery;        
             form.render();
   //普通图片上传
      var uploadInst = upload.render({
    elem: '#ajax-admin-avatar',
            exts: 'jpg|png|jpeg|gif|svg',
            size: 2048,
    url: "{:url('upload/uploadImage',['model'=>'1'])}", //改成您自己的上传接口
    done: function (result) {
        //上传完毕回调
        if (result.code === 1) {
            $('#image').attr('src', result.url);
            //this.item.prev('input').val(result.url);
            $('input[name="image"]').val(result.url);
            $('input[name="filesize"]').val(result.filesize);
            $('input[name="mine"]').val(result.mine);
            layer.msg(result.msg, {icon: 1});
        } else {
            layer.msg(result.msg, {icon: 2});
        }
    }
        });
});
</script>
{/block}

